<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>权限设置</title>
    <link rel="stylesheet" href="__TPL__/frame/layui/css/layui.css">
    <link rel="stylesheet" href="__TPL__/frame/static/css/style.css">
    <link rel="icon" href="__TPL__/frame/static/image/code.png">
    <style>
        .layui-form-item .layui-form-checkbox[lay-skin="primary"] {
            margin-top: 0px;
        }
    </style>

</head>
<body class="body">

<form class="layui-form" action="">
    <div class="layui-form-item fl">
        <div class="layui-input-inline">
            <button class="layui-btn" lay-submit="" lay-filter="edit_submit">修改提交</button>
        </div>
    </div>
    <div class="layui-form-item">
        <input type="hidden" id="group_id" value="{$Request.get.id}">
        <table class="layui-table" lay-size="sm">
            <colgroup>
                <col width="5%">
                <col width="5%">
                <col width="20%">
                <col width="40%">
                <col width="30%">
            </colgroup>
            <thead>
            <tr>
                <th></th>
                <th>ID</th>
                <th>方法名</th>
                <th>解释</th>
                <th>方法路径</th>
            </tr>
            </thead>
            <tbody>
            {volist name="all_funcs" id="vo"}
            <tr>
                <td>
                    {in name="vo.id" value="$funcs"}
                    <input name="id_check" value="{$vo.id}" lay-skin="primary" checked="" type="checkbox">
                    {else/}
                    <input name="id_check" value="{$vo.id}" lay-skin="primary" type="checkbox">
                    {/in}
                </td>
                <td align="center">{$vo.id}</td>
                <td>{$vo.name}</td>
                <td>{$vo.describe}</td>
                <td>{$vo.identify}</td>
            </tr>
            {/volist}
            </tbody>
        </table>
    </div>
</form>

<script src="__TPL__/frame/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        var form = layui.form
            , layer = layui.layer
            , $ = layui.jquery;
        form.on('submit(edit_submit)', function () {
            var check_list = $('[name=id_check]:checked');
            var func_ids = [];
            check_list.each(function () {
                func_ids.push($(this).val())
            });
            func_ids = func_ids.join(',');
            id = $('#group_id').val();
            $.ajax({
                url:'{:url("Auth/editGroupAuthPost")}',
                type:'post',
                data:{id:id,func_ids:func_ids},
                dataType:'json',
                success:function (data) {
                    if (data.code === 1){
                        var index=parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    }else{
                        layer.msg(data.msg, {icon: 1, time: 2000})
                    }
                }
            })
            return false;
        })


    });
</script>
</body>
</html>